package com.zzyl.controller;


import com.zzyl.base.ResponseResult;
import com.zzyl.dto.ResourceDto;
import com.zzyl.service.ResourceService;
import com.zzyl.vo.ResourceVo;
import com.zzyl.vo.TreeVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 资源前端控制器
 */
@Api(tags = "资源管理")
@RestController
@RequestMapping("/resource")
public class ResourceController {

    @Autowired
    private ResourceService resourceService;

    @PostMapping("/list")
    @ApiOperation(value = "资源列表", notes = "资源列表")
    @ApiImplicitParam(name = "resourceDto", value = "资源DTO对象", required = true, dataType = "ResourceDto")
    public ResponseResult<List<ResourceVo>> resourceList(@RequestBody ResourceDto resourceDto) {
       List<ResourceVo> resourceVoListList =  resourceService.resourceList(resourceDto);
       return ResponseResult.success(resourceVoListList);
    }


    @PostMapping("/tree")
    @ApiOperation(value = "菜单资源树形", notes = "菜单资源树形")
    @ApiImplicitParam(name = "resourceDto", value = "资源DTO对象", required = true, dataType = "ResourceDto")
    public ResponseResult tree(@RequestBody ResourceDto resourceDto) {
       TreeVo resourceVoListList = resourceService.tree(resourceDto);
        return ResponseResult.success(resourceVoListList);
    }


    @PutMapping
    @ApiOperation(value = "新增", notes = "新增")
    @ApiImplicitParam(name = "resourceDto", value = "资源DTO对象", required = true, dataType = "ResourceDto")
    public ResponseResult add(@RequestBody ResourceDto resourceDto) {
        resourceService.add(resourceDto);
        return ResponseResult.success(true);
    }













//    //资源修改
//    @PatchMapping
//    @ApiOperation(value = "资源修改", notes = "资源修改")
//    @ApiImplicitParam(name = "resourceDto", value = "资源DTO对象", required = true, dataType = "ResourceDto")
//    public ResponseResult update(@RequestBody ResourceDto resourceDto) {
//        resourceService.update(resourceDto);
//        return ResponseResult.success(true);
//    }


}